home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 August (Alt) / CHIP 2005-08.1.iso / program / guvenlik / syslinux-3.07.exe / parsecmd.inc < prev    next >
Encoding:
Text File  |  2004-12-21  |  3.1 KB  |  114 lines

  1. ;; $Id: parsecmd.inc,v 1.10 2004/12/21 06:30:55 hpa Exp $
  2. ;; -----------------------------------------------------------------------
  3. ;;   
  4. ;;   Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
  5. ;;
  6. ;;   This program is free software; you can redistribute it and/or modify
  7. ;;   it under the terms of the GNU General Public License as published by
  8. ;;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
  9. ;;   Boston MA 02111-1307, USA; either version 2 of the License, or
  10. ;;   (at your option) any later version; incorporated herein by reference.
  11. ;;
  12. ;; -----------------------------------------------------------------------
  13.  
  14. ;;
  15. ;; parsecmd.inc
  16. ;;
  17. ;; Command line parser code
  18. ;;
  19.  
  20.         section .text
  21.  
  22. ; -------------------------------------------------------------------------
  23. ;  getcommand:    Get a keyword from the current "getc" file and match it
  24. ;        against a list of keywords (keywd_table).  Each entry in
  25. ;        that table should have the following form:
  26. ;        <32 bit hash value> <16 bit handler offset>
  27. ;
  28. ;               The handler is called, and upon return this function
  29. ;               returns with CF = 0.  On EOF, this function returns
  30. ;        with CF = 1.
  31. ; -------------------------------------------------------------------------
  32.  
  33. getcommand:
  34. .find:
  35.         call skipspace        ; Skip leading whitespace
  36.         jz .eof            ; End of file
  37.         jc .find        ; End of line: try again
  38.  
  39.         or al,20h        ; Convert to lower case
  40.         movzx ebx,al        ; Hash for a one-char keyword
  41. .read_loop:
  42.         push ebx
  43.         call getc
  44.         pop ebx
  45.         jc .eof
  46.         cmp al,' '        ; Whitespace
  47.         jbe .done
  48.         or al,20h
  49.         rol ebx,5
  50.         xor bl,al
  51.         jmp short .read_loop
  52. .done:        call ungetc
  53.         call skipspace
  54.         jz .eof
  55.         jc .noparm
  56.         call ungetc        ; Return nonwhitespace char to buf
  57.         mov si,keywd_table
  58.         mov cx,keywd_count
  59. .table_search:
  60.         lodsd
  61.         cmp ebx,eax
  62.         je .found_keywd
  63.         lodsd            ; Skip entrypoint/argument
  64.         loop .table_search
  65.  
  66.         ; Otherwise unrecognized keyword
  67.         mov si,err_badcfg
  68.         jmp short .error
  69.  
  70.         ; No parameter
  71. .noparm:
  72.         mov si,err_noparm
  73.         mov al,10        ; Already at EOL
  74. .error:
  75.         call cwritestr
  76.         jmp short .skipline
  77.  
  78. .found_keywd:    lodsw            ; Load argument into ax
  79.         call [si]
  80.         clc
  81.         ret
  82.  
  83. .eof:        stc
  84.         ret
  85.  
  86. .skipline:    cmp al,10        ; Search for LF
  87.         je .find
  88.         call getc
  89.         jc .eof
  90.         jmp short .skipline
  91.  
  92.         section .bss
  93.         alignb 4
  94. vk_size        equ (vk_end + 3) & ~3
  95. VKernelBuf:    resb vk_size        ; "Current" vkernel
  96. AppendBuf       resb max_cmd_len+1    ; append=
  97. Ontimeout    resb max_cmd_len+1    ; ontimeout
  98. Onerror        resb max_cmd_len+1    ; onerror
  99. KbdMap        resb 256        ; Keyboard map
  100. FKeyName    resb 10*FILENAME_MAX    ; File names for F-key help
  101. KernelCNameLen    resw 1            ; Length of unmangled kernel name
  102. InitRDCNameLen    resw 1            ; Length of unmangled initrd name
  103. %if IS_SYSLINUX
  104. KernelName      resb FILENAME_MAX+1    ; Mangled name for kernel
  105. KernelCName     resb FILENAME_MAX+2    ; Unmangled kernel name
  106. InitRDCName     resb FILENAME_MAX+2    ; Unmangled initrd name
  107. %else
  108. KernelName      resb FILENAME_MAX    ; Mangled name for kernel
  109. KernelCName     resb FILENAME_MAX    ; Unmangled kernel name
  110. InitRDCName     resb FILENAME_MAX    ; Unmangled initrd name
  111. %endif
  112. MNameBuf        resb FILENAME_MAX
  113. InitRD          resb FILENAME_MAX
  114.